class Solution {
  private _size: number;

  set size(size: number) {
    this._size = size;
  }
  get size() {
    return this._size;
  }
  /**
      Write a loop that makes seven calls to console.log to output the following triangle
        #
        ##
        ###
        ####
        #####
        ######
        #######
     */
  loopTriangle() {
    let unit = "#";
    let rows = 7;
    for (let counter = 1; counter <= rows; counter++, unit += "#") {
      console.log(unit);
    }
  }

  /**
   Write a program that uses console.log to print all the numbers from 1 to 100, 
   with two exceptions. For numbers divisible by 3, print "Fizz" instead of the number, 
   and for numbers divisible by 5 (and not 3), print "Buzz" instead.
    When you have that working, modify your program to print "FizzBuzz" for numbers 
    that are divisible by both 3 and 5 (and still print "Fizz" or "Buzz" for numbers 
    divisible by only one of those).
   */
  fizzBuzz() {
    let i = 1;
    while (i <= 100) {
      if (i % 15 == 0) {
        console.log("FizzBuzz");
      } else if (i % 3 == 0) {
        console.log("Fizz");
      } else if (i % 5 == 0) {
        console.log("Buzz");
      } else {
        console.log(i);
      }
      i += 1;
    }
  }

  /**
   Write a program that creates a string that represents an 8×8 grid, using new-line 
   characters to separate lines. At each position of the grid there is either a space 
   or a # character. The characters should form a chessboard.
   */
  chessBoard() {
    let board = "";
    let initial = "#";
    for (let i = 0; i < this._size; i++) {
      for (let j = 0; j < this._size; j++) {
        board += "|" + initial;

        if (initial == "#") {
          initial = " ";
        } else {
          initial = "#";
        }
        if (j == this._size - 1) {
          board += "|\n";
        }
      }
    }

    console.log(board);
  }
}

const sol = new Solution();
sol.size = 7;
// sol.loopTriangle();
// sol.fizzBuzz();
sol.chessBoard();
